How to use a filter in a controller?
How to use a filter in a controller?
326
17-Jun-2024
Updated on 18-Jun-2024
Ashutosh Kumar Verma
18-Jun-2024Filter in AngularJS
Using filters in AngularJS is a powerful way to format and change data displayed in views. Filters can be applied directly in templates to format the data without actually changing the underlying data.
AngularJS provides some built-in filters that you can use easily in your program,
Example-
Here is an example of how to use filters in angular js program
In the example above
$scope.names
ng-repead
filter
andorderBy
filters during fetch data from json object and bind into HTML table body$scope.OrderBy
function respponsible for oders the data when click on column name in the HTML table on the View.Output-
By using filters in AngularJS templates you can keep your visual logic clean and readable while providing powerful data transformation capabilities.
Also, Read: If else statement in AngularJS.